﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using bibliotecaWPF.LogicaNegocio;

namespace bibliotecaWPF.Presentacion
{
    /// <summary>
    /// Lógica de interacción para Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            Close();//cierro aplicacion
        }

        private void btn_cons_Click(object sender, RoutedEventArgs e)
        {
           var libro= ManejaLibros.consulta(tb_cons.Text);//llamo a la funcion consulta
           if (libro != null)
           {
               var ejemp = ManejaLibros.buscaej(libro.idLibro);
               lbl_consulta.Content = libro.Titulo + "\n" + libro.Autor + "\n" + libro.Categoria.dCategoria + "\n" + libro.Año+ "\n" +ejemp.Cantidad;
           }
           else
           {
               MessageBox.Show("Libro no encontrado","Error",MessageBoxButton.OK,MessageBoxImage.Error);
           }
        }

        private void MenuItem_Click_2(object sender, RoutedEventArgs e)
        {
            Fagregar fa = new Fagregar();
            fa.ShowDialog();
        }

        private void MenuItem_Click_3(object sender, RoutedEventArgs e)
        {
            Feliminar fe = new Feliminar();
            fe.ShowDialog();
        }

        private void MenuItem_Click_4(object sender, RoutedEventArgs e)
        {
            Feditar fed = new Feditar();
            fed.ShowDialog();
        }

        private void MenuItem_Click_5(object sender, RoutedEventArgs e)
        {
            FnuevoSocio fns = new FnuevoSocio();
            fns.ShowDialog();
        }

        private void btn_limpiar_Click(object sender, RoutedEventArgs e)
        {
            lbl_consulta.Content = "";
            tb_cons.Text = "";
        }

        private void MenuItem_Click_7(object sender, RoutedEventArgs e)
        {
            Fprestamo FP = new Fprestamo();
            FP.ShowDialog();
        }

        private void MenuItem_Click_8(object sender, RoutedEventArgs e)
        {
            Fdevolucion FD = new Fdevolucion();
            FD.ShowDialog();
        }

        private void MenuItem_Click_6(object sender, RoutedEventArgs e)
        {
            FeliminarSocio es = new FeliminarSocio();
            es.ShowDialog();
        }
    }
}
